/** Copyright (C) 2007 Pascal Richter
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package jlfm.lastfm.station;

import java.util.ArrayList;
import java.util.Iterator;

import jlfm.lastfm.tag.SimpleTag;
import jlfm.lastfm.tag.Tag;

public class LastFmGlobalTagStation implements LastFmStation {
	ArrayList<Tag> tags = new ArrayList<Tag>();

	public LastFmGlobalTagStation(Tag tag) {
		setTag(tag);
	}

	public LastFmGlobalTagStation(Tag[] tags) {
		setTags(tags);
	}

	public LastFmGlobalTagStation(String tag) {
		this(new SimpleTag(tag));
	}

	public LastFmGlobalTagStation(String[] tag) {
		for (int i = 0; i < tag.length; i++) {
			addTag(new SimpleTag(tag[i]));
		}
	}

	public void setTags(Tag[] tag) {
		tags.clear();
		addTags(tag);
	}

	public void setTag(Tag tag) {
		tags.clear();
		addTag(tag);
	}

	public void addTag(Tag tag) {
		tags.add(tag);
	}

	public void addTags(Tag[] tag) {
		for (Tag element : tag) {
			addTag(element);
		}
	}

	public String getUrl() {
		String ret = "lastfm://globaltags/";
		Iterator<Tag> tagIt = tags.iterator();
		while (tagIt.hasNext()) {
			ret += tagIt.next().getName();
			ret += (tagIt.hasNext()) ? "," : "";
		}
		return ret;
	}

}
